(function () {
    let btnSubmit = document.querySelector('#btnSubmit');
    let user = document.querySelector('#username');
    let psw = document.querySelector('#password');
    let sev = document.querySelector("#checkbox");
    btnSubmit.onclick = function () {
        let _user = user.value;
        let _psw = psw.value;
        
        Cookie.setItem("name", _user);
        Cookie.setItem("password", _psw);
        // console.log(document.cookie);
        // let str =document.cookie;//name=weishi
        // let _val = str.split("=");
        // Cookie.setItem(_user,_psw)
        if (_user && _psw) {
                alert("登录成功");
                window.open("05-Cookie登录成功.html");
                if (sev.checked) {
                    //保留7天
                    Cookie.setItem('name', _user, 7);
                } else {
                    //会话级别
                    Cookie.setItem('name', _user, '');
                }
            } else {
                alert("登录失败");
            
        }
    }
})();